<?php
class StationtableQ1 {
	private $data;

	public function __construct() {
	}
	
	public function setData($data) {
		$this->data = $data;
	}

	public function display() {
		$header = array("Station ID","Name","Country","Peak Temprature"," Average Rainfall");
		echo '<table border="1">';
		echo '<tr>';
		//Echo the table headers
		foreach($header as $s) {
			echo '<th>';
			echo	$s;
			echo '</th>';
		}
		
		echo '</tr>';
		$rows = count($this->data,0);
		$cols = (count($this->data,1)/count($this->data,0))-1;
		for($i=0;$i<$rows;$i++) {
			echo '<tr>';
			for($j=0;$j<$cols;$j++) {
				echo '<td>';
				//The first column (station number) has to link to the station summary page
				if($j == 0) {
					echo '<a href="index.php?action=stationsummary&history=30&stn='.$this->data[$i][$j].'" >';
					echo $this->data[$i][$j];
					echo '</a>';
				}
				else {
					echo $this->data[$i][$j];
				}
				echo '</td>';
			}
			echo '</tr>';		
		}
		echo '</table>';
	}

}
?>